﻿USE [iKBSystem]
GO

--DomainScopeUsers-----------------
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[View_DomainScopeUsers]'))
DROP VIEW [dbo].[View_DomainScopeUsers]
GO

CREATE VIEW [dbo].[View_DomainScopeUsers]
AS
	SELECT 
		DSU.[Key] AS 'UserKey',
		DSU.[PersonKey] AS 'PersonKey',
		DSU.[DomainScopeKey] AS 'ScopeKey',
		DSU.[ThirdPartyIdentity] AS 'ThirdPartyIdentity',
		DSU.[Description] AS 'UserDescription',
		DSU.[MonitorStatus] AS 'MonitorStatus',
		DSU.[CreatedStamp] AS 'UserCreatedStamp',
		DSU.[LastUpdatedStamp] AS 'UserLastUpdatedStamp',
		DS.[Name] AS 'ScopeName',
		DS.[Code] AS 'ScopeCode',
		DS.[Type] AS 'ScopeType',
		DS.[Description] AS 'ScopeDescription'
	FROM [dbo].[DomainScopeUser] AS DSU
	LEFT OUTER JOIN [dbo].[DomainScope] AS DS
	ON DSU.[DomainScopeKey] = DS.[Key]
GO
